/**
 * 静态路由模块
 */
import { RouteRecordRaw } from "vue-router";
import { hookI18n } from "@/hooks/hookI18n";
import { ROOT_NAME, LOGIN_NAME, LAYOUT_NAME } from "@/config/modules/router";
import { ROOT_URL, HOME_URL, LOGIN_URL, LAYOUT_URL } from "@/config/modules/router";

const { t } = hookI18n();

export const constRouter: RouteRecordRaw[] = [
    {
        path: ROOT_URL,
        name: ROOT_NAME,
        redirect: HOME_URL,
    },
    {
        path: LOGIN_URL,
        name: LOGIN_NAME,
        component: () => import("@/views/login/index.vue"),
        meta: {
            title: t("router.login"),
        },
    },
    {
        path: LAYOUT_URL,
        name: LAYOUT_NAME,
        component: () => import("@/layout/index.vue"),
    },
];

export const errorRouter: RouteRecordRaw[] = [
    {
        path: "/403",
        name: "403",
        component: () => import("@/components/Error/403.vue"),
        meta: {
            title: t("error.error403Message"),
        },
    },
    {
        path: "/404",
        name: "404",
        component: () => import("@/components/Error/404.vue"),
        meta: {
            title: t("error.error404Message"),
        },
    },
    {
        path: "/500",
        name: "500",
        component: () => import("@/components/Error/500.vue"),
        meta: {
            title: t("error.error500Message"),
        },
    },
    // Resolve refresh page, route warnings
    {
        path: "/:pathMatch(.*)*",
        component: () => import("@/components/Error/404.vue"),
    },
];
